﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Reflection;

namespace JackyCode.Mock.Test
{
    [TestFixture]
    public class TestMethodData
    {
        private MethodInfo methodInfo;

        [SetUp]
        public void Initialize()
        {
            methodInfo = MethodInfoHelper.GetIOutMethod();
        }

        [Test]
        public void TestEquality()
        {
            MethodData methodData1 = new MethodData
            (
                new List<ArgumentDetail>
                {
                    new ArgumentDetail{ IsNotOut = true, Value = "Input" },
                    new ArgumentDetail{ IsNotOut = false, Value = "Output1" }
                },
                methodInfo
            );

            MethodData methodData2 = new MethodData
            (
                new List<ArgumentDetail>
                {
                    new ArgumentDetail{ IsNotOut = true, Value = "Input" },
                    new ArgumentDetail{ IsNotOut = false, Value = "Output2" }
                },
                methodInfo
            );

            Assert.AreEqual(methodData1, methodData2);
        }

        [Test]
        public void TestConstructorWithObjectArrayAndMethodInfoArg()
        {
            MethodData methodData = new MethodData(new object[] { "Input", "Output2" }, methodInfo);
            Assert.AreEqual(2, methodData.ArgumentDetails.Count);
            Assert.AreEqual("Input", methodData.ArgumentDetails[0].Value);
            Assert.IsTrue(methodData.ArgumentDetails[0].IsNotOut);
            
            Assert.AreEqual("Output2", methodData.ArgumentDetails[1].Value);
            Assert.IsFalse(methodData.ArgumentDetails[1].IsNotOut);
        }
    }
}
